package com.retain.system.service.impl;

import com.retain.system.dto.ResourceDTO;
import com.retain.system.mappers.ResourceMapper;
import com.retain.system.service.ResourceService;
import com.retain.system.vo.ResourceVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: LiuWei
 * @date: Create in 16:52 2018/12/27
 */
@Service
public class ResourceServiceImpl implements ResourceService {

    @Autowired
    ResourceMapper resourceMapper;

    @Override
    public List<ResourceVO> selectResourceByUserId(List<Long> roleIds) {
        List<ResourceDTO> resourceDTOS = resourceMapper.selectResourceByRoleIds(roleIds);
        List<ResourceVO> resourceVOS = new ArrayList<>(resourceDTOS.size());
        resourceDTOS.forEach(resourceDTO -> resourceVOS.add(ResourceVO.buildResourceVO(resourceDTO)));
        return resourceVOS;
    }
}
